import React from "react";
import { BrowserRouter, NavLink } from "react-router-dom";

const header = props => {
  const click = () => {
    const path = new BrowserRouter().history.location.pathname;
    if (path === "/news") alert("你好");
  };
  return (
    <nav>
      <NavLink to="/home">首页</NavLink>
      <NavLink to="/news">新闻</NavLink>
      <button onClick={click}>获取路由信息</button>
    </nav>
  );
};

export default header;
